﻿using System.Collections;
using System.Collections.Generic;

using UnityEngine;

/// <summary>
/// 普通直射的子弹
/// </summary>
public class NormalBullet : MonoBehaviour
{

    public static readonly string TYPE = "normal_bullet";

	void Update () {
		Vector3 p = Camera.main.WorldToScreenPoint (transform.position);
		if (p.y < -30 || p.y > Screen.height) {
            BulletManager.pullBackBullet(gameObject, TYPE);
		}
	}

    void OnTriggerEnter2D(Collider2D collider) {
        Entity entity = collider.GetComponent<Entity>();
        Entity bulletEntity = GetComponent<Entity>();
       
        if (Common.isCanAttack(bulletEntity, entity)) {
            entity.hurt(bulletEntity.damage);
            BulletManager.pullBackBullet(gameObject, TYPE);
        }
	}

    public void stop() {

    }

}


